#include "shard.h"

Shard::Shard(QObject* parent) :
  QObject(parent)
{
  region_code = 0;
  shard_code = 0;
  shard_trion_id = 0;
}

Shard::Shard(const Shard &s) :
  QObject(s.parent())
{
  region_code = s.region_code;
  shard_code = s.shard_code;
  shard_trion_id = s.shard_trion_id;
}

Shard& Shard::operator=(const Shard &s)
{
  region_code = s.region_code;
  shard_code = s.shard_code;
  shard_trion_id = s.shard_trion_id;
  return *this;
}

QString Shard::regionName()
{
  return regionStrList()[region_code];
}

QString Shard::regionShortName()
{
  return regionShortStrList()[region_code];
}

QString Shard::regionURLName()
{
  return regionURLStrList()[region_code];
}

QString Shard::shardName()
{
  return shardStrList(region_code)[shard_code];
}

int Shard::regionCode()
{
  return region_code;
}

int Shard::shardCode()
{
  return shard_code;
}

int Shard::shardTrionId()
{
  return shard_trion_id;
}

QStringList Shard::regionStrList()
{
  QStringList l;
  l.append(tr("Europe"));
  l.append(tr("North America"));
  return l;
}

QStringList Shard::regionShortStrList()
{
  QStringList l;
  l.append(tr("EU"));
  l.append(tr("NA"));
  return l;
}

QStringList Shard::regionURLStrList()
{
  QStringList l;
  l.append(tr("eu"));
  l.append(tr("us"));
  return l;
}

QStringList Shard::shardStrList(int reg)
{
  QStringList l;
  if(reg == 0)
    {
      l.append(tr("Akala"));
      l.append(tr("Argent"));
      l.append(tr("Blightweald"));
      l.append(tr("Bloodiron"));
      l.append(tr("Brisesol"));
      l.append(tr("Brutmutter"));
      l.append(tr("Brutwacht"));
      l.append(tr("Icewatch"));
      l.append(tr("Phynnious"));
      l.append(tr("Trübkopf"));
    }
  else if(reg == 1)
    {
      l.append(tr("Deepwood"));
      l.append(tr("Faeblight"));
      l.append(tr("Greybriar"));
      l.append(tr("Laethys"));
      l.append(tr("Seastone"));
      l.append(tr("Shatterbone"));
      l.append(tr("Threesprings"));
      l.append(tr("Wolfsbane"));
    }
  return l;
}

QList<int> Shard::shardTrionIdList(int reg)
{
  QList<int> l;
  if(reg == 0)
    {
      l.append(2705);
      l.append(2703);
      l.append(2701);
      l.append(2702);
      l.append(2714);
      l.append(2713);
      l.append(2711);
      l.append(2704);
      l.append(2715);
      l.append(2712);
    }
  else if(reg == 1)
    {
      l.append(1704);
      l.append(1707);
      l.append(1702);
      l.append(1708);
      l.append(1701);
      l.append(1703);
      l.append(1705);
      l.append(1706);
    }
  return l;
}

Shard Shard::getShard(int reg, int shard)
{
  Shard s;
  s.region_code = reg;
  s.shard_code = shard;
  s.shard_trion_id = shardTrionIdList(reg).at(shard);
  return s;
}

bool Shard::operator==(const Shard &s) const
{
  return shard_trion_id == s.shard_trion_id && shard_code == s.shard_code;
}
